Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackupDB 1.0 #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

BackupDB 1.0 #11

wants to merge 3 commits into from

Conversation

acatton
Copy link
Contributor

@acatton acatton commented Apr 7, 2015

This is a huge refactoring of BackupDB.

This pull request is not mergable yet. This is more of a "Request For Comments":

  • FIXME: This needs a release of spm. To test it, please install spm's master with pip install -e python-spm/.
  • FIXME: This still have TODO notes
  • FIXME: This still lack the feature python manage.py backupdb --stdout to dump the database on stdout. (The original reason I refactored it)
  • FIXME: Release spm 1.0

This is supposed to:

@acatton
Copy link
Contributor Author

acatton commented Apr 7, 2015

If @gavinwahl @rockymeza or @davesque have any feedback, I'm all ears.

suffix=backup_suffix,
ext=backup_cls.extension,
)
absolute_fname = os.path.join(backup_directory, fname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be wrapped in an os.path.abspath? It doesn't appear that get_backup_directory returns an absolute path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you're totally right. I'm just not sure where to get the absolute path. Should it be os.path.join(PROJECT_PATH, BACKUP_DIR), because BACKUP_DIRECTORY doesn't have to be an absolute directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since os.path.abspath is idempotent, why don't you just pass the output of get_backup_directory through it to ensure it's absolute.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/django/django/blob/master/django/conf/project_template/project_name/settings.py#L16

PROJECT_PATH is more of a Fusionbox concept, but most django installs probably have BASE_DIR.

That being said. I would much rather have the user decide that and ask that they provide absolute URLs instead of us guessing what things they have in their settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also might consider calling os.path.expanduser before calling abspath.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rockymeza I don't think it being relative now will matter. Is there something specific that you're concerned about expanding relative paths to absolute paths?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the builtin Django settings are absolute, like MEDIA_ROOT, etc.

I'm just opposed to guessing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acatton When you say guessing, are you referring to using backups/ as the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abspath seems like a good idea.

But I don't think we should call os.path.expanduser. If you want to do it in your settings BACKUP_DIRECTORY = os.path.expanduser(yourpath), that's fine. What if I want my backups to go in '~backups/' in my project?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See fc7d478

@pipermerriam
Copy link
Contributor

Cool to see this getting love. Looks like a great start.

Might I suggest you look into using tox to test this across the different database backends? I think it will make your life a lot easier.

@davesque
Copy link
Contributor

davesque commented Apr 7, 2015

Looks nice. I never really liked the "do_backup_..." function system. Having backend classes is more consistent with the design of other django libraries.

@acatton
Copy link
Contributor Author

acatton commented Apr 7, 2015

@pipermerriam regarding tox, see 7548740. I'm not sure why travis didn't pick it up yet :-/ .

Thank you Piper Merriam for the suggestion.
@pipermerriam
Copy link
Contributor

A suggestion. It looks like you have a pretty complex script section that juggles the env variables and runs the correct tox env. I've found it a lot easier to do all of this within tox and merely list out the tox envs that need to be run within travis. Tox lets you list all of the envs with tox -l.

Since tox has facilities for doing env variable setting and everything within the individual environments, it becomes a lot easier to get all of your envs running with the right env variables, etc.

I think this will make it a bit easier for people to run the full suite on their own machines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use polymorphism for database backup backupdb doesn't support multiple connections
4 participants